////////////////////////////////////////////////////////////
/* VipAccount Script Original written by Scarface//Odin  //
 *                                                      //
 * This script can be easily edited to be              //
 * used for your server. Throughout the script        //
 * are comments on what each thing does so that      //
 * you can edit this. You can create custom         //
 * teleporting locations and menus.                //
 *                                                //
 * Originally written for use with Moon++        //
 */                                             //
/////////////////////////////////////////////////

#include "StdAfx.h"
#include "Setup.h"


#define VIP_ITEM_ID1 99997             //Define here your Vip Item
#define VIP_ITEM_ID2 99998             //Define here your Vip Item
#define VIP_ITEM_ID3 99999             //Define here your Vip Item



void AddItem(Player *plr, uint32 id){
    Item *item;
    item = objmgr.CreateItem( id, plr);
    if(!plr->GetItemInterface()->AddItemToFreeSlot(item)){delete item;}
    
    
}
void VIPCheck (Player *plr){
  static unsigned acct = NULL;
  static unsigned vip = NULL;
  static QueryResult *getVip = NULL;
  static QueryResult *getAcct = NULL;
       getAcct = CharacterDatabase.Query("SELECT `acct` FROM `characters` WHERE `guid` = '%i'", plr->GetGUIDLow());
       acct = getAcct->Fetch()[0].GetUInt32();
       getVip = CharacterDatabase.Query("SELECT `vip` FROM `accounts` WHERE `acct` = '%i'", acct);
       vip = getVip->Fetch()[0].GetUInt32();
  if (vip && 1) AddItem(plr, VIP_ITEM_ID1);
  if (vip && 2) AddItem(plr, VIP_ITEM_ID2);
  if (vip && 4) AddItem(plr, VIP_ITEM_ID2);
}

void SetupVIPAccount(ScriptMgr* mgr){
  mgr->register_hook(SERVER_HOOK_EVENT_ON_CHARACTER_CREATE, &VIPCheck);
}
